package com.dehui.traders.ui.market.platedetail;

import com.dehui.traders.bean.BaseListResponse;
import com.dehui.traders.bean.PlateListBean;
import com.dehui.traders.service.NetImpl;

import java.util.List;

import me.goldze.mvvmhabit.base.BaseViewModel;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class PlateDetailViewModel extends BaseViewModel{

    private PlateDetailActivity context;

    public PlateDetailViewModel(PlateDetailActivity context) {
        super(context);
        this.context = context;
    }

    public void tradeupdownlist(String typeCode, int page) {
        Call<BaseListResponse<PlateListBean.PlateData>> call = NetImpl.tradeupdownlist(typeCode, page);
        call.enqueue(new Callback<BaseListResponse<PlateListBean.PlateData>>() {
            @Override
            public void onResponse(Call<BaseListResponse<PlateListBean.PlateData>> call, Response<BaseListResponse<PlateListBean.PlateData>> response) {
                BaseListResponse<PlateListBean.PlateData> body = response.body();
                int status = body.status;
                if(status == 200){
                    List<PlateListBean.PlateData> list = body.result;
                    context.updataList(list);
                }
            }

            @Override
            public void onFailure(Call<BaseListResponse<PlateListBean.PlateData>> call, Throwable t) {

            }
        });

    }
}
